package itsm.isperp.framework.data.csv;

import org.springframework.stereotype.Component;

/**
 * example:
 * <p>
 * LOAD DATA LOCAL INFILE 'c:/Data/mysql/transaction_upload.csv'
 * </p>
 * <p>
 * INTO TABLE transaction_upload
 * </p>
 * <p>
 * FIELDS TERMINATED BY ','
 * </p>
 * <p>
 * ENCLOSED BY '"'
 * </p>
 * <p>
 * ESCAPED BY '\\'
 * </p>
 * <p>
 * LINES TERMINATED BY '\r\n';
 * </p>
 */
@Component
public class CvsImportExecutor {

	/**
	 * 
	 * @param tableName
	 * @param cvsFileName
	 */
	public static void execute(String tableName, String cvsFileName) {
		StringBuilder sb = new StringBuilder();

		sb.append("LOAD DATA LOCAL INFILE '").append(cvsFileName).append("'");
		sb.append("INTO TABLE  ")
				.append(tableName)
				.append(" FIELDS TERMINATED BY ',' ENCLOSED BY '\"'  ESCAPED BY '\\'  LINES TERMINATED BY '\r\n'");
	}
}
